package com.ruoyi.web.controller.myController;

import com.ruoyi.system.domain.LiveArticle;
import com.ruoyi.system.domain.vo.Results;
import com.ruoyi.system.mapper.LiveArticleMapper;
import com.ruoyi.system.service.LiveArticleService;
import com.ruoyi.web.controller.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class LiveAricleController {
    @Autowired
    private LiveArticleService liveArticleService;

    @GetMapping("/getLiveArticleList")
    public Results getLiveArticleList(LiveArticle liveArticle){
        List<LiveArticle> liveArticles = liveArticleService.selectLiveArticle(liveArticle);
        return new Results(200,"sucess",liveArticles);
    }

    @PostMapping("/insertLiveArticle")
    public  Results inserLiveArticle(@RequestBody LiveArticle liveArticle){
        return new Results(200,"sucess",liveArticleService.insertLiveArticle(liveArticle));
    }
    @GetMapping("/deleteLiveArticle/{aid}/{uid}")
    public Results deleteLiveArticle(@PathVariable("aid") Long aid,@PathVariable("uid") Long uid){
        return new Results(200,"sucess",liveArticleService.deleteLiveArticleById(aid,uid));
    }
    @PostMapping("/updateLiveArticle")
    public Results updateLiveArticle(@RequestBody LiveArticle liveArticle){
        return new Results(200,"sucess",liveArticleService.updateLiveArticleById(liveArticle));
    }
}
